package com.baidu.videoseries.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.baidu.videoseries.R;
import com.baidu.videoseries.ToolbarActivity;
import com.baidu.videoseries.constant.Config;
import com.baidu.videoseries.util.PageUtil;

public class ContentActivity extends ToolbarActivity {

    private Fragment mFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public void initNav() {
        this.mIndex = getIntent().getIntExtra(Config.Key.INDEX, -1);
        if (mIndex == PageUtil.Index.VLC) {
            hideActionbar();
            requestLandScape();
        }
        if (mIndex==PageUtil.Index.TEST){
            hideActionbar();
            requestLandScape();
            hideStatusBar();

        }
    }

    @Override
    public void init() {
        if (mIndex == -1) return;
        this.mFragment = PageUtil.getFragment(mIndex);
        this.mFragment.setArguments(getIntent().getExtras());
        mManager.beginTransaction()
                .add(R.id.fragment_container, mFragment)
                .commit();
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (mFragment != null) this.mFragment.onActivityResult(requestCode, resultCode, data);
    }
}
